package cn.codingjc.peekaboo.api.web;

import cn.codingjc.peekaboo.application.service.sql.SqlService;
import cn.codingjc.peekaboo.domain.domain.sql.dto.TableSchemaDTO;
import cn.codingjc.peekaboo.domain.domain.sys.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @date: 2023/5/4
 * @author: Codingjc
 * @className: SQLController
 **/
@RestController("/sql")
public class SqlController {

    @Autowired
    private SqlService sqlService;

    @PreAuthorize("hasPermission('sql:generate:all')")
    @PostMapping("/generateAll")
    public ResultVO generateSchema(@RequestBody TableSchemaDTO tableSchemaDTO){
        return sqlService.generateSchema(tableSchemaDTO);
    }
}
